# -*-coding = utf-8 -*-

# @Time: 2021/5/2 15:39
# @Author: bistro
# @File: p554.py
# @Software: PyCharm
from typing import List


class Solution:
    def leastBricks(self, wall: List[List[int]]) -> int:
        hash_map = {}
        cols = len(wall)
        for i in range(cols):
            total = 0
            for j in wall[i]:
                total += wall[i][j]
                hash_map[total] = hash_map.get(total, 0) + 1
        print(hash_map)
        hash_map.pop(sum(wall[0]))
        ans = cols
        for k in hash_map.keys():
            ans = min(ans, ans - hash_map[k])
        return ans
